import React from 'react'
import {
  useParams,
  useNavigate,
  useLocation,
  useSearchParams,
} from 'react-router-dom'
export default function About() {
  const params = useParams()
  const location = useLocation()
  const [search, setSearch] = useSearchParams()
  const navigate = useNavigate()
  console.log(params) //params是一个对象,对象里面可以拿到传递过来的路由参数
  console.log(location)
  console.log(search) // 注意: 空对象.看不到数据,因为数据被隐藏起来了
  console.log(search.get('xxx')) //必须使用get,才能获取到指定的数据
  console.log(search.get('yyy'))
  return (
    <>
      <h1>About</h1>
      <button
        onClick={() => {
          // navigate(-1)
          setSearch('xxx=aaa&yyy=bbb')
        }}
      >
        返回
      </button>
    </>
  )
}
